home *** CD-ROM | disk | FTP | other *** search
/ Hyper Stacks 1994 May / Hyper Stacks (Pacific HiTech)(1994)[Mac].iso / Magazines / Windoid 1.5 / wind4.txt < prev    next >
Encoding:
Text File  |  1988-01-03  |  23.0 KB  |  575 lines  |  [TEXT/MACA]

  1. WINDOID Issue #4
  2.  
  3. A Publication for the Informed HyperCard User
  4. and the Newsletter for the  Apple HyperCard User Group
  5.  
  6. Editor -- David Leffler
  7.  
  8. In the fourth issue of WINDOID, we address more of the many questions and
  9. problems people have sent in.  Quite a number of people have expressed interest
  10. in moving a group of buttons or fields on a card.  Sioux Lacy, one of our
  11. outstanding HyperCard testers, has given us a way to group buttons and/or
  12. fields and move them, in a group, within a card and even onto other cards or
  13. stacks.  Sioux has also written for us an article on Finding multi-word strings
  14. in blocks of text.  This is one that everyone has asked for.
  15.  
  16. Phil Wyman, with assistance from Steve All, two more great HyperCard testers,
  17. have given us further HyperCard user tips.  We really appreciate all of the
  18. cards people have sent us with the tips they have found.  In this way we can
  19. pass on useful tips to many hundreds of HyperCard users.
  20.  
  21. Paul Foraker, our newest tester, has submitted an AutoLink script.  Using this
  22. great little shortcut for scripting buttons gives you another productivity tip
  23. I am sure you will find interesting.
  24.  
  25. Steve Maller has done it again!  ResCopier is his latest XCMD effort to give us
  26. a safe, elegant, and easy way to move resources around in HyperCard.  This
  27. version is his "shipping" version and does not have a time bomb in it.  You are
  28. free to give it away to your HyperCarding friends.  This is one stack that
  29. people who do not have it will lust for.  The version to look for is the
  30. Rescopier "Beanie" version 2.78
  31.  
  32. Sioux Lacy has given us Groupies 1.3, featured in this issue of WINDOID.  By
  33. the time you read this Groupies 1.4 will be available on BBS's everywhere with
  34. additional functionality.  This is a must stack for serious HyperCard users.  I
  35. really appreciate Sioux's efforts in bringing us all of these great articles
  36. and I am equally sure that you will also.
  37.  
  38. These stacks are on the Apple HyperCard User Group file server and can be
  39. obtained only here in Cupertino.  If your favorite bulletin board does not have
  40. them, please ask them to have someone upload them.
  41.  
  42. I have had many requests for issues of WINDOID.  If you would like a copy, or
  43. copies, please send a Self Addressed Stamped Envelope (SASE) to the address
  44. listed on THE FORM for each issue.  Thanks for your continued interest in
  45. WINDOID.  Together we are making a difference!
  46. ==========
  47.  
  48. AutoLink
  49. by Paul Foraker
  50.  
  51. Shortly after you get HyperCard installed on your hard disk, you may notice
  52. that you are collecting a large number of other people's stacks. One way of
  53. keeping track of all of them is to stuff them into a folder and put a button
  54. for them on a card in your Home stack. Since the original Home card already
  55. comes with 19 buttons (and room for about 24), you might want to make another
  56. card for holding buttons that take you to your miscellaneous stacks. To avoid
  57. having to name and link all the buttons on a new card to the stacks I've
  58. collected, I wrote a variation on Danny Goodman's script which takes you to a
  59. stack even though the button has no script or link.
  60.  
  61. In this version, a button named "new button" opens the familiar Standard File
  62. dialog and then gets the name of whatever stack you select, changes the name of
  63. itself (the button) to the selected stack, then goes there.  If the button
  64. already has a name (other than "new button"), the script simply goes to the
  65. stack.  This eliminates the necessity for linking or scripting multiple buttons
  66. on a card.
  67.  
  68. To start from scratch from your Home card, select New Card (CMD-N) and title
  69. the new card "BackYard" (or anything else fun). Type the script below into the
  70. script window for the card.  (You can skip over typing the comments if you
  71. wish.) Then make a new button (you can select an icon for it -- I use the
  72. generic stack icon). Now hold down the Option key and drag copies of the "new
  73. button" around onto your card.  (You can use the Shift key to constrain the
  74. movement so theyUre lined up neatly.)
  75.  
  76. Next, select the Browse tool again and click on one of your new buttons. YouUll
  77. get Standard File asking you "where is the stack you want?"  Double click on
  78. one of the stacks in the list, the new button will get a name change, and
  79. youUll be off to the new stack. From there, you can hit the escape (~) key to
  80. go right back to the BackYard to AutoLink another button.
  81.  
  82. --AutoLink script
  83. --variation on Danny Goodman's script
  84. --by Paul Foraker
  85.  
  86. -- Please remember that a % is an Option-Return in ASCII TEXT format.
  87. --Editor
  88.  
  89. on mouseUp
  90.   put the short name of this stack %
  91.   into thisStack                    --saving the name for
  92.                                     --use later
  93.    get the short name of the target --puts the 'short' name of the
  94.                                     --button you clicked on into 'it'
  95.    if it is "new button" then       --Oh boy... a new stack has arrived!
  96.      push card                      --saves the BackYard card id
  97.                                     --so we can come back to it
  98.      set lockMessages to true       --stops any other scripts from running
  99.      set lockScreen to true         --freezes the screen so we're not
  100.                                     --distracted by fast moving cards.
  101.      go stack "the stack you want?" --since there is no stack by that
  102.                                     --name, HyperCard will respond by
  103.                                     --asking you where it is.
  104.                                     --Standard File will open and you
  105.                                     --can select a stack
  106.                                     --or click on Cancel.
  107.      get the short name of this stack    --here we're asking for the
  108.                                          --short name of the 'new' stack
  109.  
  110.     if it is thisStack then        --checking for clicking on the Cancel button
  111.        pop card                       --go back to our BackYard card
  112.        set lockScreen to false        --unlocking the screen display
  113.        exit mouseUp                   --pretend it never happened
  114.      end if                           --end of checking for 'cancel'
  115.  
  116.     put it into stackName      --putting short name of the stack into
  117.                                --'stackName'
  118.      pop card                  --go back to our BackYard card
  119.      set the name of the target to stackName      --rename the button
  120.      set showName of the target to true         --we want to see the name
  121.      set the script of the target to empty  --make sure there's no script in
  122.                                             --the button
  123.      set lockScreen to false           --unlocking the screen display
  124.      set lockMessages to false         --now messages can fly around again.
  125.    end if                              --marks the end of the loop
  126.                                        --for a 'new button.'
  127.  
  128.    --now, we make sure you didn't click on the card or background:
  129.      if the short name of target is the short name of this card then exit
  130. mouseUp
  131.      if the short name of target is the short name of this bkgnd then exit
  132. mouseUp
  133.  
  134.    visual iris open to black      --just for fun
  135.    go STACK it                    --'it' will be either the new stack or
  136.                                   -- one that's already been identified
  137.    end mouseUp
  138. ==========
  139.  
  140. HyperCard Hints
  141. by Phil Wyman
  142.  
  143. 1.     There are some interesting properties in HyperTalk that you may not know
  144. about:
  145.  
  146. a.  <the version> is a global property which tells you which version of
  147. HyperCard you are currently using.  This property will become very useful after
  148. new versions are released. Since the new versions will have added features that
  149. old versions do not understand, stack developers will want to check to see if
  150. their stack is currently running on a version of HyperCard that supports those
  151. new features.
  152.  
  153. b.  <the name> is another global property. It will tell you that the name of
  154. the program is HyperCard. I have not found a way to use this yet, so if anyone
  155. has any ideas, let me know.
  156.  
  157. c.  <the diskspace> is a global property which will tell you how many bytes you
  158. have left on the drive that the current stack is located on.
  159.  
  160. 2.    You can send a message up the hierarchy manually by using the message
  161. box.  For instance, if you want an OPENSTACK message sent without having to
  162. reopen your stack, just type OPENSTACK into the message box and hit return or
  163. enter. Any handler, starting with any handler in the current card, which uses
  164. OPENSTACK, will receive that message.
  165.  
  166. Some users are having trouble sending their own messages. In a script, you can
  167. just type the name of your message on a line by itself and that message will be
  168. sent. If HyperCard does not find a handler with that message, it will throw up
  169. a dialog telling you it can't understand <message>.
  170.  
  171. You can also send a message with the <send> command. You can have difficulty
  172. with the <send> command if you are trying to send across stacks. Try going to
  173. the stack first before using <send>. For example:
  174. send mouseUp to button 1 of card 1 of stack "Home"
  175. will generate a HyperCard error "expected end of line after send". To get the
  176. "mouseup"  message to the button, try this:
  177. go to card 1 of stack "Home"
  178. send mouseup to button 1
  179.  
  180. 3.    When you are printing your script from the script editor, you do not have
  181. to print the whole script. If you want to just print a portion of your script,
  182. then select the part you want, then click on the print button. Only your
  183. selected text will print.
  184.  
  185. 4.   The Tab key moves you between fields on a card in the order of their field
  186. number (which can be changed with Bring Closer and Send Farther).  But a useful
  187. fact for data entry is that Shift-Tab navigates you through fields in reverse
  188. order.
  189.  
  190. 5.   Choosing a selection with the Selection tool can leave you with a lot of
  191. extra white space surrounding your selection.  And you may already know that
  192. Command-S shrinks a selection rectangle until there is no surrounding white
  193. space.  What if you want a rectangular selection but no extra white space?
  194. Hold down the Command key before selecting with the Selection tool and just
  195. that will happen.
  196.  
  197. 6.   If you are writing commercial stacks and need to restrict the user-level,
  198. you may wish to tell users in your About Box that they can access "Full Menus"
  199. by holding down the Command key before clicking the menu.
  200.  
  201. 7.   So you think that those tiny pictures in "Recent" are neat?  You can
  202. create them yourself.  Copy a card and hold down the Shift key when pasting it
  203. back in.  You'll get an image of the card in miniature (but no actions from
  204. buttons or fields to type into).
  205. ====================
  206.  
  207. Finding a MultiWord String
  208. by Sioux Lacy
  209.  
  210. -- Please remember that a % is an Option-Return in ASCII TEXT format.
  211. --Editor
  212.  
  213. There are three ways in which the script writer can inquire about the presence
  214. of a string in a block of text:  FIND, CONTAINS and OFFSET.
  215. These can be used separately or in combination.
  216. The FIND command will highlight the next occurence of the first word of the
  217. string if all words in the string are somewhere on the card.
  218. Another option is to test if a particular container (field or variable)
  219. CONTAINS the string.
  220. This test will determine an exact match on the entire string.
  221. The function OFFSET will return the character in the container on which the
  222. match begins.  This can also be used to test IF the field/variable includes the
  223. string, since if it does NOT, offset will return 0.  Depending on the context
  224. of the search, the script writer may opt for one or a combination of these.  If
  225. the scope of the search is small, and across known fields, CONTAINS or OFFSET
  226. can be used.  However, if the search is across many fields in a large stack,
  227. FIND is a good mechanism to narrow down the number of fields that have to be
  228. examined to see if they CONTAIN the string.
  229.  
  230. To FIND a multi-word string
  231.  
  232. For example, you would like to find an exact match for the string "Hello
  233. there".   You will discover that HyperCard is generous in its find criteria,
  234. and also matches the following:  "Hello world.  Is there life out there?"
  235.  
  236. This can be problematic if the search is taking place inside a handler, rather
  237. than at the control of a human who can continue to hit the return key.   The
  238. way to circumvent this is to do your match in 2 steps.  Supposing you expect
  239. the match to be in a background field, try calling a function (until you've
  240. searched the entire stack) that does this:
  241.  
  242. function multiWordFind string
  243.    repeat with x = 1 to the number of bkgnd fields
  244.        if field x contains string then return "FOUND in field " & x
  245.    end repeat
  246.    return "NOT FOUND"
  247. end multiWordFind
  248.  
  249. (If you expected the match to be in a card field, repeat also for the number of
  250. card fields.)
  251.  
  252. on searchStackFor string
  253.      set lockScreen to true
  254.      find string
  255.      if the result is "Not Found" then cleanExit%
  256.      "This stack doesn't contain: " & string
  257.                  --Use the above two lines or use the script
  258.                     --at the end as an alternate to find offset.
  259.      put the id of this card into startedHere
  260.      repeat
  261.        get multiWordFind (string)
  262.        if word 1 of it is "FOUND" then cleanExit it
  263.        go next card -- so a subsequent find won't find the same
  264.                     -- card over again
  265.        find string
  266.        if the id of this card is startedHere then cleanExit%
  267.        "This stack doesn't contain: " & string
  268.      end repeat
  269. end searchStackFor
  270.  
  271. on cleanExit prompt
  272.    put prompt
  273.    set lockScreen to false
  274.    exit to HyperCard
  275. end cleanExit
  276.  
  277.       --Use the following as an alternate to determine the offset.
  278.  
  279. if word 1 of it is "FOUND" then
  280.    cleanExit it && "at character position" && offsetB
  281.    (string, the value of word 3 to 4 of it)
  282. end if
  283.  
  284. ====================
  285.  
  286. Grouping and Moving Buttons and Fields
  287. by Sioux Lacy
  288.  
  289. Sioux Lacy, one of the outstanding HyperCard testers, has donated this script
  290. to provide you, the user, an often-desired script for moving a group of buttons
  291. and/or fields around on a card.  We are always trying to give you what you ask
  292. for, so please let us know if this script is helpful to you.
  293. --Editor
  294.  
  295. Many users have asked about grouping objects.  This stack presents a method for
  296. assigning to a group any number of buttons or fields, and then being able to
  297. move that group as a unit, or copying and pasting that group onto another card.
  298. This is accomplished with a series of handlers in a card field, called
  299. "menuField".  It looks somewhat like a menu, accepts clicks on any command that
  300. it displays, and can be copied and pasted onto another card.
  301.  
  302. The menuField has a Help option that allows the user to read about each of its
  303. options.
  304.  
  305. Note that the menuField needs to be a card field in order to work properly.
  306. And, when a group has been pasted, it will require re-grouping if its group
  307. identity is to work in the new context.  Also, since it is difficult to select
  308. overlapping objects to be members of a group, it is recommended that they be
  309. positioned so they don't overlap.
  310.  
  311. Groupies 1.3 by Sioux Lacy, November 6, 1987.
  312. AppleLink* comments to me at LACY1, or send mail to:
  313. Sioux Lacy
  314. MS 27-AQ
  315. 20525 Mariani Ave.,
  316. Cupertino, CA 95014.
  317.  
  318. -- Please remember that a % is an Option-Return in ASCII TEXT format.
  319. --Editor
  320.  
  321. --Groupies 1.3 by Sioux Lacy
  322. --November 6, 1987
  323.  
  324. on NewField
  325.   get editBkgnd
  326.   if it is true then
  327.     set editBkgnd to false
  328.     put "The menuField cannot be a bkgnd field." &&
  329.     "Delete this field & paste again.."
  330.     exit New Field
  331.   end if
  332.   put "Help" & return & "Group" & return & "Move" & return %
  333.   & "Copy" & return & "Paste" & return & "Clear" & return %
  334.   into card field id (the id of me)
  335.   choose browse tool
  336. end NewField
  337.  
  338. on mouseUp
  339.   put the id of me into myID
  340.   put the mouseV into clickLoc
  341.   put "HelpMe,NewGroup,MoveGroup,CopyGroup,PasteGroup,ClearGroup" %
  342.   into messages
  343.   repeat with x = 1 to the number of lines in card field id myID
  344.     put "" into char 1 of line x of card field id myID
  345.   end repeat
  346.   put the textHeight of me into height
  347.   put item 2 of the rect of me + height into baseLine
  348.   repeat with x = 1 to the number of lines in card field id myID
  349.     if clickLoc < baseLine then
  350.       put "C" into char 1 of line x of card field id myID
  351.       send item x of messages to me
  352.       exit mouseUp
  353.     end if
  354.     add height to baseLine
  355.   end repeat
  356. end mouseUp
  357.  
  358. on HelpMe
  359.   ask "Which option would you like help on?" with "Group"
  360.   if it is empty then exit HelpMe
  361.   if it is "Group" then
  362.     put "This option will let you specify objects to be grouped.
  363.   else if it is "Move" then
  364.     put "This option will let you move the group."
  365.   else if it is "Copy" then
  366.     put "This option used in conjunction with Paste will copy" && %
  367.     "& paste the group."
  368.   else if it is "Paste" then
  369.     put "This option used in conjunction with Copy will copy" && %
  370.     "& paste the group."
  371.   else if it is "Clear" then
  372.     put "This option will delete all the objects in the group."
  373.   else put "Never heard of that option."
  374. end HelpMe
  375.  
  376. on NewGroup
  377.   global objectList
  378.   put "Shift-click to include objects in group. Option-click when done."
  379.   put empty into objectList
  380.   repeat
  381.     set cursor to 2
  382.     wait until the mouseClick
  383.     put the mouseLoc into thisClick
  384.     set cursor to 4
  385.     if the optionKey is down then exit repeat
  386.     repeat with x = the number of card buttons down to 1
  387.    if isClickWithinObject (thisClick, rect of card btn x) then
  388.      put "card btn id " & the id of card btn x & "," after objectList
  389.      exit repeat
  390.    end if
  391.     end repeat
  392.     repeat with x = the number of bkgnd buttons down to 1
  393.        if isClickWithinObject (thisClick, rect of bkgnd btn x) then
  394.      put "bkgnd btn id " & the id of bkgnd btn x & "," after objectList
  395.      exit repeat
  396.    end if
  397.     end repeat
  398.     repeat with x = the number of card fields down to 1
  399.        if isClickWithinObject (thisClick, rect of card field x) then
  400.      put "card field id " & the id of card field x & "," after objectList
  401.      exit repeat
  402.    end if
  403.     end repeat
  404.     repeat with x = the number of bkgnd fields down to 1
  405.        if isClickWithinObject (thisClick, rect of bkgnd field x) then
  406.      put "bkgnd field id " & the id of bkgnd field x & "," after objectList
  407.      exit repeat
  408.    end if
  409.     end repeat
  410.   end repeat
  411.   put empty into last char of objectList
  412.   put "The group consists of: " & objectList
  413. end NewGroup
  414.  
  415. function isClickWithinObject thisClick, theRect
  416.   if ((item 1 of theRect) <= (item 1 of thisClick)) and %
  417.   ((item 2 of theRect) <= (item 2 of thisClick)) and %
  418.   ((item 3 of theRect) >= (item 1 of thisClick)) and %
  419.   ((item 4 of theRect) >= (item 2 of thisClick)) then
  420.     return true
  421.   else return false
  422. end isClickWithinObject
  423.  
  424. on MoveGroup
  425.   global objectList
  426.   if objectList is empty then
  427.     put "There are no objects in the group."
  428.     exit MoveGroup
  429.   end if
  430.   put "Click and drag the group with mouse down. There is an initial delay."
  431.   wait until the mouseClick
  432.   put the mouseLoc into myLoc
  433.   set cursor to 4
  434.   put empty into horizontalOffset
  435.   put empty into verticalOffset
  436.   repeat with i = 1 to the number of items in objectList
  437.     put the location of item i of objectList into theLoc
  438.     put item 1 of theLoc - item 1 of myLoc & "," after horizontalOffset
  439.     put item 2 of theLoc - item 2 of myLoc & "," after verticalOffset
  440.   end repeat
  441.   put empty into last char of horizontalOffset
  442.   put empty into last char of verticalOffset
  443.   set cursor to 2
  444.   repeat while the mouse is down
  445.     get the mouseLoc
  446.     repeat with i = 1 to the number of items in objectList
  447.       put it into theLoc
  448.       add item i of horizontalOffset to item 1 of theLoc
  449.       add item i of verticalOffset to item 2 of theLoc
  450.       set location of item i of objectList to theLoc
  451.     end repeat
  452.   end repeat
  453. end MoveGroup
  454.  
  455. on CopyGroup
  456.   global WhereTheGroupIs
  457.   set lockScreen to true
  458.   choose field tool
  459.   click at the location of me
  460.   doMenu "Copy Field"
  461.   choose browse tool
  462.   put the long id of this card into WhereTheGroupIs
  463.   put "Go to another card, type cmd-V, & choose Paste from the menuField."
  464.   set lockScreen to false
  465. end CopyGroup
  466.  
  467. on PasteGroup
  468.   global whereTheGroupIs, objectList
  469.   if whereTheGroupIs = empty then put "Please choose Copy from the menuField."
  470.   else if objectList = empty then put "There are no objects in the group."
  471.   else
  472.     set cursor to 4
  473.     set lockMessages to true
  474.     set lockScreen to true
  475.     repeat with i = 1 to the number of items in objectList
  476.       push this card
  477.       go to WhereTheGroupIs
  478.       get item i of objectList
  479.       if word 2 of it is "btn" then choose button tool
  480.       else choose field tool
  481.    if word 1 of it is "bkgnd" then set editBkgnd to true
  482.       click at the location of it
  483.       type "C" with commandKey
  484.       pop card
  485.       type "V" with commandKey
  486.    set editBkgnd to false
  487.     end repeat
  488.     choose browse tool
  489.     put "To group these new objects, " & %
  490.      "choose Group from the menuField."
  491.     set lockScreen to false
  492.   end if
  493. end PasteGroup
  494.  
  495. on ClearGroup
  496.   global objectList
  497.   put "The group consists of: " & objectList
  498.   answer "Clearing group is not undoable. Are you sure?" %
  499.   with "Yes" or "Cancel"
  500.   if it is "Cancel" then exit ClearGroup
  501.   repeat with i = the number of items in objectList down to 1
  502.     get item i of objectList
  503.     if word 2 of it is "btn" then choose button tool
  504.     else choose field tool
  505.     click at the location of it
  506.     type "X" with commandKey
  507.   end repeat
  508.   choose browse tool
  509.   put empty into objectList
  510. end ClearGroup
  511. ==================
  512.  
  513. We hope you have enjoyed reading WINDOID and have found it to be interesting
  514. and informative. We care enough to take the time to give you the most
  515. up-to-date information about HyperCard, and we would like to make a request for
  516. a little of your time. There is a form that follows this editorial; please fill
  517. it out if you will. We are very interested in hearing from you. What sort of
  518. stacks are you using, what kind of stacks are you creating, and what are your
  519. joys and frustrations in using HyperCard.
  520.  
  521. You have the unique opportunity to communicate directly with Bill, Dan, and the
  522. entire HyperCard development team. We really want to know what you would like
  523. to see in HyperCard and are more than willing to give you what you want. What
  524. we need to make this happen is your input. Let us know what you think. We can
  525. address it in WINDOID or perhaps the next revision of HyperCard. You can make a
  526. difference in the world by communicating with us. Don't pass up the
  527. opportunity!
  528. ==========
  529.  
  530. If you have a bug, suggestion, comment, or just want to know
  531. the best way to do something in HyperCard, you can fill out the form and send
  532. it to:
  533.  
  534. AHUG c/o David Leffler
  535. Apple Computer, Inc.
  536. MS/27-AQ
  537. 20525 Mariani Ave.
  538. Cupertino, CA 95014
  539.  
  540. Or copy the format and
  541. Apple-Link(TM) it to:
  542. HYPERBUG$
  543.  
  544. TELL HYPERCARD
  545. You can use this form to notify the HyperCard team of problems, bugs, and
  546. enhancement requests.
  547.  
  548. THE FORM:
  549.  
  550. Please use the following form to make a difference in the world:
  551.  
  552. Date:
  553. Name:
  554. Address:
  555. Phone #:
  556. Versions of:
  557.  a.  HyperCard:
  558.  b.  Associated software:
  559.  c.  System Software:
  560.        1. System
  561.        2. Finder
  562.        3. ImageWriter file
  563.        4. LaserWriter file
  564.        5. Any others
  565. Type of Macintosh:
  566. Peripherals:
  567. Description of problem, suggestions or comments:
  568.  
  569.  
  570. Please fill this form out as completely as possible and send it to us.  You
  571. will be glad you did!
  572.  
  573.  
  574. [ painstakingly uploaded to CIS by Raines Cohen of BMUG's HyperCard SIG ]
  575.